package com.itheima.exer.homework.hw1009;

import java.io.*;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Comparator;
import java.util.List;

public class NumberTest1 {
    public static void main(String[] args) throws IOException {
        BufferedReader br = new BufferedReader(new FileReader(new File("exercises\\c.txt")));
        String s = br.readLine();
        System.out.println(s);
        String[] split = s.split(",");
        List<Integer> list =new ArrayList<>();
        for (int i = 0; i < split.length; i++) {
            list.add(Integer.parseInt(split[i]));
        }
        Collections.sort(list, new Comparator<Integer>() {
            @Override
            public int compare(Integer o1, Integer o2) {
                int i = o1 - o2;
                return i;
            }
        });
        StringBuffer sb = new StringBuffer();
        for (int i = 0; i < list.size(); i++) {
            if (i == list.size()-1){
                sb.append(list.get(i));
            }else {
                sb.append(list.get(i)+",");
            }
        }
        String s1 = sb.toString();
        BufferedWriter bw = new BufferedWriter(new FileWriter(new File("exercises\\c.txt")));
        bw.newLine();
        bw.write(s1);
        br.close();
        bw.close();

    }
}
